<template>
  <div class="box-2">
    <div class="right">
      <a href="javascript:void (0)" v-routers="{path:'/'}"></a>
    </div>
    <div class="card">
      <el-input style="width: 260px;margin-right: 10px" placeholder="请输入课程名称"></el-input>
      <el-button class="defaultBtn" icon="el-icon-search" color="#333" type="info">新增</el-button>
      <el-button class="defaultBtn" icon="el-icon-refresh-right"  type="info">重置</el-button>
    </div>
    <div class="card">
      <el-button class="defaultBtn" icon="el-icon-plus" @click="dialogVisible=true" type="info">新增</el-button>
    </div>

    <el-table :data="tableData" border style="width: 100%">
      <el-table-column type="index" label="序号" width="80"></el-table-column>
      <el-table-column prop="taskName" label="任务名称" min-width="180"></el-table-column>
      <el-table-column prop="room" label="教室名称" min-width="180"></el-table-column>
      <el-table-column prop="major" label="专业名称" min-width="180"></el-table-column>
      <el-table-column prop="class" label="班级名称" min-width="180"></el-table-column>
      <el-table-column prop="teacher" label="授课老师" min-width="180"></el-table-column>
      <el-table-column prop="time" label="课程时间" min-width="300"></el-table-column>
        <el-table-column prop="type" label="状态" min-width="180">
        <template #default="{row}">{{type(row)}}</template>
      </el-table-column>
      <el-table-column prop="crateTime" label="创建时间" min-width="180"></el-table-column>
      <el-table-column fixed="right" align="center" label="操作" min-width="180">
        <el-button size="mini" class="defaultBtn" type="info">删除</el-button>
        <el-button size="mini" class="defaultBtn" type="info">编辑</el-button>
      </el-table-column>
    </el-table>
    <div class="page">
      <el-pagination background layout="prev, pager, next" :total="1000"></el-pagination>
    </div>

    <el-dialog title="任务管理" :visible.sync="dialogVisible" width="600px" :before-close="handleClose">
      <el-form ref="form" :model="form" label-width="80px" >
        <el-form-item label="任务名称">
          <el-input v-model="form.name" placeholder="请输入任务名称"></el-input>
        </el-form-item>
        <el-form-item label="班级名称">
          <el-select style="width: 100%;" v-model="form.region" placeholder="请选择班级名称">
            <el-option label="计算机科学技术一班" value="1"></el-option>
            <el-option label="计算机科学技术二班" value="2"></el-option>
            <el-option label="计算机科学技术三班" value="3"></el-option>
            <el-option label="计算机科学技术四班" value="4"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="专业名称">
          <el-input disabled v-model="form.name" placeholder="请输入专业名称"></el-input>
        </el-form-item>
        <el-form-item label="授课老师">
          <el-select style="width: 100%;" v-model="form.region" placeholder="请选择授课老师">
            <el-option label="王洒汗" value="1"></el-option>
            <el-option label="李领域" value="2"></el-option>
            <el-option label="张开放" value="3"></el-option>
            <el-option label="赵四钱" value="4"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="上课时间">
          <el-date-picker
              style="width: 100%;"
              v-model="form.date1"
              type="datetimerange"
              range-separator="至"
              start-placeholder="开始上课时间"
              end-placeholder="结束上课时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="任务状态">
          <el-radio-group v-model="form.resource">
            <el-radio :label="0">启用</el-radio>
            <el-radio :label="1">禁用</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="info" class="defaultBtn" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogVisible:false,
      tableData: [
          {
            taskName:'计算机网络基础',
            room:'逸夫楼605教室',
            class:'计算机科学与网络3班',
            major:'计算机科学技术',
            teacher:'高浓',
            time:'2022-12-31 8:00 - 2022-12-31 9:00',
            type:0,
            crateTime:'2022-12-31 12:00:00'
          }],
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: 0,
        desc: ''
      }
    }
  },
  methods:{
    type(item){
      console.log(item)
      switch (item.type){
        case 0:{
          return '闲置'
        }
        case 1:{
          return  '启用'
        }
      }
    },
    handleClose(){
      this.dialogVisible=false
    }
  }
}
</script>

<style scoped lang="scss">
.box-2{
  width: 92%;
}
.card{
  width: 100%;
  margin: 10px 0;
}
.page{
  width: 100%;
  display: flex;
  justify-content: right;
  margin-top: 10px;
}
::v-deep(.el-pagination.is-background .el-pager li:not(.disabled).active ){
  background: #333 !important;
  color: #fff;
}
</style>
